package com.yswl.yeeduo.ui.bean;


import java.io.Serializable;
import java.util.Map;

import com.yswl.yeeduo.tool.KStringTool;
import com.yswl.yeeduo.ui.db.WxUserInfoDao;

/**
 * 微信获取必要的用户信息
 * 
 * @author Administrator
 * 
 */
public class WXUserInfo implements Serializable{
	/**
	 * 
	 */
	private static final long serialVersionUID = -125790930554508857L;
	public String nickname = "";
	public int sex = -1;
	public String province = "";
	public String city = "";
	public String country = "";
	public String headimgurl = "";


	public WXUserInfo(String nickname, int sex, String province, String city, String country, String headimgurl) {
		super();
		this.nickname = nickname;
		this.sex = sex;
		this.province = province;
		this.city = city;
		this.country = country;
		this.headimgurl = headimgurl;
	}


	public WXUserInfo() {
		super();
	}


	@Override
	public String toString() {
		return "WXUserInfo [nickname=" + nickname + ", sex=" + sex
				+ ", province=" + province + ", city=" + city + ", country="
				+ country + ", headimgurl=" + headimgurl + "]";
	}
	
	
	public static void saveWxUserInfo(Map<String, Object> info) {
		String city = (String) info.get("city");
		String country = (String) info.get("country");
		String headimgurl = (String) info.get("headimgurl");
		String headNetUrl = "http://s.lifedoo.cn:8088/M00/00/03/CqgtmFYcoBWABGLzAAAKfwn89nU078.png";
		// headimgurl = headimgurl == null || headimgurl.equals("") ? headNetUrl
		// : headimgurl;
		headimgurl = KStringTool.isEmpty(headimgurl) ? headNetUrl : headimgurl;
		String province = (String) info.get("province");
		int sex = (Integer) info.get("sex");
		String nickname = (String) info.get("nickname");
		WXUserInfo userInfo = new WXUserInfo(nickname, sex, province, city, country, headimgurl);
		// 通过数据库
		WxUserInfoDao.getInstance().insert(userInfo);
	}
}
